<template>
  <view class="container">
    <view class="top">
      <view class="f1">需支付金额</view>
      <view class="f2"><text class="t1">￥</text><text class="t2">{{ opt.money }}</text></view>

      <view class="f1">订单号</view>
      <view class="f3"><text class="t3">{{ opt.ordernum }}</text></view>

      <view class="f4">二维码</view>
      <view class="qr-box" style="margin: 40rpx 30rpx 0rpx 30rpx;">
        <canvas canvas-id="qrcode" v-show="qrShow" style="width: 150px;margin: 0 auto;" />
      </view>

      <image style="width: 360rpx;height: 80rpx;"
        src="https://hniuniu-oss.oss-cn-hangzhou.aliyuncs.com/wap/hmsande.jpg"></image>
      <view class="f1" style="margin: 30rpx;">
        操作提示：截图保存，扫码支付，也可以点击“复制链接”微信搜索打开支付。
        <!-- 支持微信、银联、云闪付及各大银行APP扫码支付 -->
      </view>

      <button type="primary" style="width: 200rpx;border-radius: 15rpx;margin-top: 100rpx;" @tap="copy">复制链接</button>
    </view>
  </view>
</template>

<script>
var app = getApp();
import uQRCode from '@/static/js/uqrcode.js'
export default {
	data() {
		return {
			opt:{},
			loading:false,
			isload: false,
			ttitle:''
		};
	},

	onLoad: function (opt) {
		//this.opt = app.getopts(opt);
		this.opt = JSON.parse(decodeURI(opt.dd));
		if(this.opt.buyType == 11){
					this.ttitle='微信';
				}else if(this.opt.buyType == 12){
					this.ttitle='支付宝';
				}else if(this.opt.buyType == 12){
					this.ttitle='银联';
				}else if(this.opt.buyType == 90){
					this.ttitle='云闪付';
				}
				console.log("二维码：："+this.opt.code);
		this.qrFun(this.opt.code)
	},
	onShow() {
		var tt = this;
	    this.timer = setInterval(function() {
			tt.cheng(tt.opt.ordernum)
	    }, 10000);
	},
	onUnload() {//离开页面前清除计时器
		var that = this;
	    clearInterval(that.timer);
	    that.timer = null;
	},

  methods: {
	  copy: function() {
		  var that = this;
	  	uni.setClipboardData({
	  		data: that.opt.code,
	  		success: function () {
	  			getApp().error('复制成功')
	  		}
	  	});
	  },
		//**生成二维码**//
		qrFun: function(text) {
			this.qrShow = true
			uQRCode.make({
				canvasId: 'qrcode',
				componentInstance: this,
				text: text,
				size: 150,
				margin: 0,
				backgroundColor: '#ffffff',
				foregroundColor: '#000000',
				fileType: 'jpg',
				errorCorrectLevel: uQRCode.errorCorrectLevel.H,
				success: res => {}
			})
		},
		gotourl:function(tourl, opentype){
			var that = this;
			if(app.globalData.platform == 'mp' || app.globalData.platform == 'h5'){
				if (tourl.indexOf('miniProgram::') === 0) {
					//其他小程序
					tourl = tourl.slice(13);
					var tourlArr = tourl.split('|');
					console.log(tourlArr)
					that.showOpenWeapp();
					return;
				}
			}
			app.goto(tourl, opentype);
		},
		cheng:function(onum){
			var that = this;
			app.post('ApiPay/sandehmcheck', {ordernum: that.opt.ordernum}, function (res) {
				app.showLoading(false);
				if (res.status == 1) {
					// that.gotourl(that.opt.tourl,'reLaunch');
					return;
				}
			});

		},

  }
}
</script>
<style>
.top {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 60rpx
}

.top .f1 {
  height: 60rpx;
  line-height: 60rpx;
  color: #939393;
  font-size: 24rpx;
}

.top .f2 {
  color: #101010;
  font-weight: bold;
  font-size: 72rpx;
  height: 120rpx;
  line-height: 120rpx
}

.top .f3 {
  color: #101010;
  font-weight: bold;
  font-size: 72rpx;
  height: 40rpx;
  line-height: 40rpx
}

.top .f2 .t1 {
  font-size: 44rpx
}

.top .f3 .t3 {
  font-size: 30rpx
}

.top .f4 {
  height: 60rpx;
  line-height: 120rpx;
  color: #939393;
  font-size: 24rpx;
}
</style>
